Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rollup/plugin-terser

Package Overview
Dependencies
Maintainers
4
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rollup/plugin-terser

Generate minified bundle

  • 0.4.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.3M
decreased by-2.79%
Maintainers
4
Weekly downloads
 
Created

What is @rollup/plugin-terser?

@rollup/plugin-terser is a Rollup plugin that integrates Terser, a JavaScript minifier, into the Rollup build process. It helps in reducing the size of the JavaScript bundles by removing unnecessary whitespace, comments, and other non-essential code elements, as well as performing advanced optimizations like dead code elimination.

What are @rollup/plugin-terser's main functionalities?

Basic Minification

This feature allows you to perform basic minification of your JavaScript code. By including the `terser` plugin in the Rollup configuration, the output bundle will be minified, reducing its size.

const { terser } = require('@rollup/plugin-terser');

module.exports = {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs'
  },
  plugins: [terser()]
};

Custom Terser Options

This feature allows you to customize the Terser options. For example, you can enable top-level variable and function name mangling and remove console statements from the output bundle.

const { terser } = require('@rollup/plugin-terser');

module.exports = {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs'
  },
  plugins: [
    terser({
      mangle: {
        toplevel: true
      },
      compress: {
        drop_console: true
      }
    })
  ]
};

Source Map Generation

This feature allows you to generate source maps for the minified code. By enabling the `sourcemap` option in both the Rollup output configuration and the Terser plugin, you can create source maps that help in debugging the minified code.

const { terser } = require('@rollup/plugin-terser');

module.exports = {
  input: 'src/index.js',
  output: {
    file: 'dist/bundle.js',
    format: 'cjs',
    sourcemap: true
  },
  plugins: [terser({ sourcemap: true })]
};

Other packages similar to @rollup/plugin-terser

Keywords

FAQs

Package last updated on 05 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc